package com.xbongbong.pro.enums.businessrule.enums;

import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.pro.constant.RuleFilterConditionConstant;
import lombok.Getter;

import java.util.Objects;

/**
 * https://xbb.yuque.com/lfwuxq/vsf9sv/ap8doo
 * @author 吴峰
 * @date 2021/01/06 9:46
 */
@Getter
public enum RuleFilterConditionEnum {

    /**
     *
     */
    TEXT(FieldTypeEnum.TEXT, RuleFilterConditionConstant.TEXT),
    TEXTAREA(FieldTypeEnum.TEXTAREA, RuleFilterConditionConstant.TEXTAREA),
    SERIALNO(FieldTypeEnum.SERIALNO, RuleFilterConditionConstant.SERIALNO),

    COMBO(FieldTypeEnum.COMBO, RuleFilterConditionConstant.COMBO),
    RADIO_GROUP(FieldTypeEnum.RADIO_GROUP, RuleFilterConditionConstant.RADIO_GROUP),

    COMBO_CHECK(FieldTypeEnum.COMBO_CHECK, RuleFilterConditionConstant.COMBO_CHECK),
    CHECKBOX_GROUP(FieldTypeEnum.CHECKBOX_GROUP, RuleFilterConditionConstant.CHECKBOX_GROUP),

    USER_GROUP(FieldTypeEnum.USER_GROUP, RuleFilterConditionConstant.USER_GROUP),
    DEPT_GROUP(FieldTypeEnum.DEPT_GROUP, RuleFilterConditionConstant.DEPT_GROUP),

    USER(FieldTypeEnum.USER, RuleFilterConditionConstant.USER),
    DEPT(FieldTypeEnum.DEPT, RuleFilterConditionConstant.DEPT),
    DEPARTMENTID(FieldTypeEnum.DEPARTMENTID, RuleFilterConditionConstant.DEPARTMENTID),
    CREATORID(FieldTypeEnum.CREATORID, RuleFilterConditionConstant.CREATORID),

    ADDRESS(FieldTypeEnum.ADDRESS, RuleFilterConditionConstant.ADDRESS),
    // 数字
    NUM(FieldTypeEnum.NUM, RuleFilterConditionConstant.NUM),
    // 日期
    DATETIME(FieldTypeEnum.DATETIME, RuleFilterConditionConstant.DATETIME),
    // 创建时间
    ADDTIME(FieldTypeEnum.ADDTIME, RuleFilterConditionConstant.ADDTIME),
    // 更新时间
    UPDATETIME(FieldTypeEnum.UPDATETIME, RuleFilterConditionConstant.UPDATETIME),
    //阶段推进器
    STAGE_THRUSTER(FieldTypeEnum.STAGE_THRUSTER, RuleFilterConditionConstant.STAGE_THRUSTER),
    MANUAL_SIGN(FieldTypeEnum.MANUAL_SIGN, RuleFilterConditionConstant.MANUAL_SIGN),

    // 以下为saas字段
    LINK_BUSINESS_SINGLE(FieldTypeEnum.LINK_BUSINESS_SINGLE, RuleFilterConditionConstant.LINK_BUSINESS_SINGLE),
    STAR(FieldTypeEnum.STAR, RuleFilterConditionConstant.STAR),
    VIDEO(FieldTypeEnum.VIDEO, RuleFilterConditionConstant.VIDEO),
    ;

    private FieldTypeEnum fieldTypeEnum;

    private String[] loginList;

    RuleFilterConditionEnum(FieldTypeEnum fieldTypeEnum, String[] loginList) {
        this.fieldTypeEnum = fieldTypeEnum;
        this.loginList = loginList;
    }

    public static RuleFilterConditionEnum getByCode(Integer fieldType) {
        for (RuleFilterConditionEnum ruleFilterConditionEnum: values()) {
            if (Objects.equals(ruleFilterConditionEnum.getFieldTypeEnum().getType(), fieldType)) {
                return ruleFilterConditionEnum;
            }
        }
        return null;
    }
}
